/**
 * 2
 *  
 * @Author : roryrywang
 * @DateTime : 24-9-8 下午1:57
 */

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    vector<long long> cnts(n);
    for (int i = 0; i < n; ++i) {
        cnts[i] = (long long) (i + 1) * (n - i);
    }
    // 反向迭代器
    sort(cnts.rbegin(), cnts.rend());

    long long result = 0;
    for (int i = 0; i < n; ++i) {
        result += a[i] * cnts[i];
    }

    cout << result << endl;

    return 0;
}